home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / jcool01.zip / TODO < prev    next >
Text File  |  1992-11-30  |  17KB  |  475 lines

  1. --- ToDo list Dec 1992 by Jamshid Afshar (jamshid@emx.utexas.edu) ---
  2.  
  3. o ascii_duration() is stupid about years  1 Jan 1992 - 31 Dec 1991 is
  4. *not* "1 year 1 day".
  5.  
  6. o Fix bugs in random, quaternion, and complex -- code probably
  7. assumes 32-bit ints.  Their test_*.C programs have bugs which crash
  8. the machine, so I commented them out of the tests\makefile.
  9.  
  10. o Turn inlining back on (-vi) once I get a BC++ that inlines without
  11. causing weird run-time bugs.
  12.  
  13. o Get rid of Envelope class.  Besides probably not being strictly
  14. valid C++ because it relies on temporaries hanging around, I think
  15. compiler optimizations could reap a lot of its benefits.  Also, maybe
  16. same optimization could be done less obscurely by using Shared data
  17. members instead.
  18.  
  19. o Why is NT_Stack_Entry first_element a long instead of a pointer?!
  20.  
  21. o Change Range<Bounds> back to Range<T, T max, T min> since this is
  22. legal after all (a BC++ 3.1 bug didn't allow original code). (that's
  23. why ex3_12 is commented out in examples/makefile).
  24.  
  25. o Remove all use of <values.h> -- use INT_MIN,etc. instead of MAXINT,etc.
  26. (mostly just in Complex and Rational)
  27.  
  28. o Change all #include <misc.h> to #include <cool/misc.h> so don't have
  29. to have cool and cool/.. in path.  Maybe rename (or remove) Boolean.
  30.  
  31. o Get rid of (int n, Type t, ...) ctors in List, Vector, etc. since
  32. they cause overloading ambiguities and they're rarely useful (only
  33. built-in types).
  34.  
  35. o Get rid of all the "== TRUE" tests in (*compare)() calls.  Add
  36. template parameter Comparator instead of using compare functions
  37.  
  38. o For all array indexes change ulong->size_t, long->size_t but check
  39. arithmetic since sometimes relies on negative values.
  40.  
  41. o Redo error handling; code relies on coolcpp's ability to to
  42. stringize template parameter name; do something upwardly compatible
  43. with throw (maybe something like Johan Bengston's paper).
  44.  
  45. o Use CoolList_H instead of LISTH as macro wrapper so as not to
  46. conflict with other List.h headers.  Also get rid of #ifndef around
  47. each #include statement -- let the compiler do this optimization.
  48.  
  49. o Possibly #include <cool/*.C> in each header file unless next version
  50. of compilers implement automatic instantiation of template functions.
  51.  
  52. o Maybe change to more modern, POSIX Regexp?
  53.  
  54.  
  55.  
  56. ---- The following is the todo list that was in the GECOOL2.1 package ----
  57.  
  58. File: List.h
  59.  
  60.   Create nodes with a reference count of 1, then eliminate all the
  61.   reference method calls on new nodes. (new nodes are ALWAYS referenced
  62.   by something...)
  63. done - LGO 10/2/89
  64.  
  65. 1. Fix bug in division and modulo of 2 bignums.
  66.     Reason: Overflow is not always catched with fixnum multiplication.
  67.     Fix in estimate_q_hat.
  68. DONEFile: Date_Time.C
  69.  
  70. localtime(long) has 1 array bound write error and "delete (tm*) t" causes
  71. warings from Purify: freeing t which is not the begining of a malloc bloc.
  72. IGNORE
  73.  
  74. Fix memory leak caused by tzset() called in set_tz(time_zone).
  75. This call is done by localtime already, and only once.
  76. DONE
  77.  
  78.  
  79. Vector.h
  80.  Bug in ... in constructor, using va_arg.
  81.  The arguments in ... cannot be passed by reference. macro va_arg does funny
  82.  casting and does not enforce argument passing correctly, especially in case
  83.  of passing by reference.
  84.  
  85. prepend, remove_duplicates
  86.  Don't call constructors or operator= on the elements of this->data
  87.  
  88.  
  89.  operator[], fill, copy
  90.  When checking array boundaries, instead of
  91.    if (n < 0 || n >= this->number_elements)    // If index out of range
  92.  do:
  93.    if ((unsigned long) n >= this->number_elements)
  94.  The cast makes negative n look very large.
  95. DONE
  96.  
  97.  operator==, position, search, push_new, remove, remove_duplicates, replace,
  98.  replace_all
  99.  This sits in a loop calling (*this->compare).  Instead, make this->compare
  100.  default to NULL, and have two loops: one for the default case where
  101.  operator== on the value type is used, and another calling (*this->compare).
  102. operator== and search are special cases
  103. DONE
  104.  
  105.  search, push_new, remove, remove_duplicates, replace, replace_all
  106.  there ought to be a general purpose, protected searching method, which is
  107.  fast (see above) used by all these methods.
  108. Used find - DONE
  109.  
  110.  copy, push, push_new, append, prepend, insert_before, insert_after
  111.  There needs to be a general purpose protected grow method, like in String.
  112.  The grow method should call resize to do most of the work.
  113. DONE
  114.  
  115.  reverse
  116.  This could be re-written to use pointers instead of indices.
  117.  Dividing the length by two can be eliminated, and a check for when
  118.  the top and bottom pointers meet or cross substituted.
  119.  
  120.  remove, remove_duplicates, prepend, insert_before, insert_after
  121.  These need to be re-written to do their work in-place (i.e. no copying
  122.  to a temporary)  The new and delete calls should go away.
  123. DONE - prepend left as-is because it's likely to grow the vector
  124.  
  125.  insert_before, insert_after
  126.  There are two versions of each of these.  They should all call a common
  127.  private method which does the real work of inserting something at some index.
  128. DONE
  129.  
  130.  type##_vector_heap_sort
  131.  This needs to be merged into the sort method.  There's no reason for
  132.  this friend function to exist, and it causes an extra .o file to be
  133.  produced by the implement script.
  134. DONE
  135.  
  136.  sort
  137.  Use the ansi C qsort function, instead of having one in the template.
  138.  If you feel that the heap sort algorithm is superior, write a general
  139.  purpose hsort function, with the same calling sequence as qsort.
  140.  hsort can be in the library instead of the template.
  141. DONE
  142.  
  143.  Vector<Type>(int n, Type* data)
  144.  Write a new constructor which makes a fixed size vector which shares
  145.  storage with the data argument
  146. DONE
  147.  
  148. Matrix.h
  149.  Bug in ... in constructor, using va_arg.
  150.  The arguments in ... cannot be passed by reference. macro va_arg does funny
  151.  casting and does not enforce argument passing correctly, especially in case
  152.  of passing by reference.
  153.  
  154.   In all the constructors:
  155.   Allocate all the column data in one chunk, then fill in the
  156.   addresses in the row vector.
  157. DONE
  158.  
  159.   ~Matrix, operator=, 
  160.   When deleting the matrix, delete only the first row, then the column
  161.   (see above)
  162. DONE
  163.  
  164.   operator+ operator* etc. (All non-destructive operators)
  165.   DON'T RETURN A REFERENCE TO STORAGE ON THE HEAP.  Return a Matrix on
  166.   the stack by value.  Use the copy constructor, then the associated
  167.   operator?= function.
  168. DONE
  169.  
  170.   operator*=
  171.   This allocates row vectors on the heap, then doesn't delete them!
  172.   Anyway, this needs to be re-written to use a single temporary row
  173.   vector, instead of a whole new matrix.
  174.  
  175.   inline Type& operator[](int row, int col)
  176.   New method, does the same thing as the current get method.
  177. DONE
  178.  
  179.   inline const Type& get (int, int);
  180.   change this to return Type, instead of a const reference to type.
  181.   (We're always dealing with numbers, right? so there's no need to
  182.   deal in references to Type.)
  183. DONE
  184.   
  185.   Nuke the map and reduce methods
  186. DONE
  187.  
  188. File: Stack.h
  189.  
  190. Fix memory leak, in &=, |=, ^=, -=. 
  191. The leak comes from returning by value, a stack allocated on the heap.
  192. The stack is copied and returned, and the one on the heap is never deleted.
  193. DONE
  194.  
  195. Add a general purpose protected grow method
  196. DONE
  197.  
  198.   push pushn
  199.   use the grow method.
  200. DONE
  201.  
  202.  operator==, find, position
  203.  These sit in a loop calling (*this->compare).  Instead, make this->compare
  204.  default to NULL, and have two loops: one for the default case where
  205.  operator== on the value type is used, and another calling (*this->compare).
  206. DONE
  207.  
  208.  Stack<Type>(int n, Type* data)
  209.  Write a new constructor which makes a fixed size Stack which shares
  210.  storage with the data argument.
  211. DONE
  212. Queue.h
  213.  
  214.   unget, put
  215.   Call a general purpose grow method, which calls resize to do most of
  216.   the work. 
  217. DONE
  218.  
  219.   remove
  220.   Rewrite to remove in-place, instead of copying the whole queue.
  221. DONE
  222.  
  223.   set_length
  224.   Currently, if the length specified is greater than the size, the
  225.   length is set to the size.  This is wrong.  It should resize the
  226.   queue to be large enough for length.
  227.  
  228.   The whole implementation is inefficient.  number_elements should NOT
  229.   be maintained, but calculated.  Things like get and put should be
  230.   trivial inlines, not 20 line functions.
  231. DONE
  232.  
  233.   I think the names first_in and last_in are confusing.  I would call
  234.   them in and out.
  235. DONE
  236.  
  237.   In addition, since queue always works sequentially,
  238.   it's better to use pointers instead of array references [].
  239.  
  240.  
  241.   There needs to be additional overloaded versions of get and unput, which
  242.   take a reference to a return value, and return a Boolean success flag.
  243. DONE
  244. file: Association.h
  245.  
  246. find
  247.   re-write this to not use reset next and key.  find is heavily used,
  248.   and setting current position inside the loop (instead of using a local
  249.   variable in a register) slows it down
  250. template <class Ktype, class Vtype>
  251. Boolean Association<Ktype,Vtype>::find (const Ktype& key) {
  252.   for (long i = 0; i < this->number_elements; i++) // Search for key in list
  253.    if ((*this->compare_keys_s)(this->data[i].get_first(), key) == TRUE) {
  254.      this->current_position = i;    // Set current position        
  255.      return TRUE;            // Return success
  256.     }
  257.   return FALSE;                // Return failure
  258. }
  259.  
  260. remove()
  261.   re-write to invoke the base class remove() method.
  262.  
  263. remove (const Ktype& key)
  264.   re-write to do a find(key) followed by remove()
  265.  
  266. put
  267.   put needs to call the general purpose protected grow method, that
  268.   Vector should have (see cool/Vector/TODO)
  269.  
  270.  
  271. Make the (base) ~Hash_Table() destructor method inline.
  272.  
  273. Get rid of the Hash_Table<Tkey,Tval>::Hash_Table<Tkey,Tval> () constructor
  274. and give the constructor that takes a size a default argument:
  275. Hash_Table<Tkey,Tval>::Hash_Table<Tkey,Tval> (int n=1) : (n) {
  276. Do the same for the base Hash_Table class.
  277.  
  278. Move the "traversed" flag in the current position out of Hash_Table, and
  279. only support it in the Set class.
  280.  
  281. Use the following for setting current position:
  282. #define make_current_position(hash, index) ((hash << 8) | index)
  283. this->current_position.data = make_current_position(hash, index);
  284. This helps out compilers that don't optimize well (-g option)
  285. and will be faster, if the "traversed" flag is left in.
  286.  
  287. The resize method can be improved by using the overloaded operator new
  288. in cfront 2.0 to only construct the new buckets, avoid calling the
  289. destructor for the old buckets, and avoid operator= by using memcpy (see
  290. Vector<Type>::resize)
  291.  
  292. Don't try saving the current position in the remove method.  Since it
  293. doesn't always work, it should never be done.
  294.  
  295. Re-write Boolean Hash_Table<Tkey,Tval>::remove (const Tkey& key);
  296. to do a find(key) followed by remove();
  297. (this reduces the amount of code generated for each hash table)
  298.  
  299. Operator= shouldn't make the sizes of the two hash tables the same,
  300. it should just copy the contents.  The current algorithm should be
  301. an optimization for the case where the two sizes are already equal,
  302. or less than.
  303.  
  304. Operator== shouldn't depend on the two hash table's having the same
  305. number of buckets.  It should first check for the number of entries
  306. being the same (which it does), then for each element in the first hash
  307. table, do a find on the second, and compare the values.  The current
  308. algorithm should be used as an optimization for the case where the two
  309. hash tables have the same number of buckets.
  310. DONE
  311.  
  312. find, put, get and remove all have the following inner-loop code:
  313.   long prime = hash_primes[this->current_bucket]; // Prime number of buckets
  314.   unsigned long hash = ((*this->h_function)(key)) % prime; // Get hash value
  315.   int index = this->items_in_buckets[hash];
  316.   for (int i = 0; i < index; i++)        // For each item
  317.     if ((*this->compare_keys)(key,this->table[hash].data[i].key) == TRUE)
  318.       //DO SOMETHING
  319.  
  320. Get rid of the function call in the inner loop by making compare_keys
  321. default to NULL, and moving the default code to a general purpose find
  322. method.  Do the same for default_hash.
  323. The above code can be replaced with:
  324.  
  325.   unsigned long hash;
  326.   int i = this->internal_find(key, &hash);
  327.   if (i < 0) DO_SOMETHING
  328.   else DO_SOMETHING_ELSE
  329.  
  330. // Returns bucket index, or -1 if not found
  331. // If hash_return is non-null, return the hash value
  332. // If hash_return is null, this function returns the hash value
  333. // (this feature is used by the resize method)
  334.  
  335. long Hash_Table<Tkey, Tval>::internal_find(Tkey key, long* hash_return) {
  336.   long prime = hash_primes[this->current_bucket]; // Prime number of buckets
  337.   long hash;
  338.   //
  339.   // Get the hash value
  340.   //
  341.   if (this->h_function != NULL)
  342.     hash = ((*this->h_function)(key)) % prime;
  343.   else {
  344. #if ISSAME(Tkey, charP) || ISSAME(Tkey, String)
  345.     hash = sxhash(key) % prime;
  346. #else
  347.     if (sizeof (key) <= 4)
  348.       hash = (((unsigned long) key) >> 3) % prime;
  349.     else
  350.       hash = sxhash((char*) &key) % prime;
  351. #endif
  352.   }
  353.   if (hash_return == NULL)
  354.     return hash;
  355.   else
  356.     hash_return = hash;
  357.   //
  358.   // Find the bucket entry
  359.   //
  360.   int index = this->items_in_buckets[hash];
  361.   Tkey##_##Tval##_hash_pair bucket[BUCKET_SIZE] = this->table[hash].data;
  362.   if (this->compare_keys == NULL) {    // DEFAULT COMPARE FUNCTION
  363. #if ISSAME(T1, charP)
  364.  #ifndef C_STRINGH
  365.    extern int strcmp (const char*, const char*);
  366.  #endif
  367.     for (int i = 0; i < index; i++)        // For each item
  368.       if (!strcmp(key,bucket[i].key))
  369.         return i;
  370. #else
  371.     for (int i = 0; i < index; i++)        // For each item
  372.       if (key == bucket[i].key)
  373.         return i;
  374. #endif
  375.  
  376.   } else {                // VARIABLE COMPARE FUNCTION
  377.     for (int i = 0; i < index; i++)        // For each item
  378.       if ((*this->compare_keys)(key, bucket[i].key))
  379.         return i;
  380.   }
  381.   return -1;
  382. }
  383.  
  384. This method replaces default_hash and Default_Hash_Compare.  In
  385. addition, it eliminates several function calls in all the lookup
  386. methods, and reduces code duplication (i.e. reduces the amount of code
  387. generated for each hash table)
  388. File: Set.h
  389.  
  390. Enforce const for set operations + - ^ |, etc...
  391. Currently, const cannot be enforced because the curpos pointer changes.
  392. Save curpos and restore it, so that const is enforced.
  393. DONE
  394.  
  395. ********
  396. *** All the comments in cool/Hash_Table/TODO apply to Set
  397. ********
  398.  
  399. operator| operator^
  400.   These can be re-written to copy "this" to a temporary, and call
  401.   the matching operator|= or operator^= method.
  402.   For example:
  403.  
  404. template <class Type> 
  405. Set<Type> Set<Type>::operator| (Set<Type>& s) {
  406.   Set<Type> result(this->length() + s.length()); // Temporary variable
  407.   for (this->reset(); this->next (); )        // For each entry in 1st set
  408.     result->put (this->value());        // Put entry to result set
  409.   result.operator|=(s);
  410.   return result;                // Return resulting union
  411. }
  412.  
  413. test_Set depends on the hash sequence of the Sun/4.  This needs to be fixed.
  414. 1. Check AVL tree for balancing after put and remove. ex9_7.C
  415.    the tree can be balanced further...
  416.  
  417. All files:
  418.  
  419. Split the template files into header (.h) and source (.C). 
  420. Eliminate Coolcpp syntax, and make all templates conformant to AT&T C++ 3.0,
  421. and GNU g++ 2.0.
  422.  
  423. Efficient initialization in constructors by passing initial values to slots
  424. directly, rather that making assignments in body of constructors.
  425.  
  426. Implement association and other classes based on stack rather than vector,
  427. since LIFO is usally a better than FIFO. Currently there is a lot of shuffling
  428. and copying inside of vector, each time an element is inserted or deleted.
  429.  
  430.  
  431. Make sure that operator= works if left hand side is the same object as right 
  432. hand side of =.
  433. DONE
  434.  
  435. A lot of COOL objects copy by ints, and so create array bounds, read writes
  436. on free memory, when the sizeof(object) is not an integral multiplier of
  437. sizeof(int).
  438. Use Purify to check for access errors.
  439. DONE
  440.  
  441. Fix memory leaks, using infinite loop and watching memory usage with top4.1.
  442. Use Purify to check for leaks.
  443. DONE
  444.  
  445.  
  446.  
  447. All files:
  448.  
  449. Either implement sharing of nodes in the trees, or do explicit copy.
  450. Currently the trees share the nodes without any reference count.
  451. Choose to do explicit deep copy for now.
  452. DONE
  453.  
  454. Fix memory leak for Binary_Tree and N_Tree.
  455. Make destructor virtual where necessary.
  456. DONE 
  457.  
  458. File AVL_Tree.h:
  459.  
  460. Fix balancing bug in AVL tree.
  461. see ../examples/section9/ex9_7.C for bug occurence.
  462. ./list/todo
  463. ./bignum/todo
  464. ./date_tim/todo
  465. ./vector/todo
  466. ./matrix/todo
  467. ./stack/todo
  468. ./queue/todo
  469. ./associat/todo
  470. ./hash_tab/todo
  471. ./set/todo
  472. ./examples/section9/todo
  473. ./todo
  474. ./tree/todo
  475.